package com.list88zhu.android.sunflower.http;

import com.list88zhu.android.sunflower.http.impl.DefaultConfig;

/**
 * <pre><code>
 *
 *  </code></pre>
 *
 * @author zhuyingming@qmtv.com
 * @date 2018/9/9
 */
public class AppClient {

    private static AppClient instance;

    private AppClient() {}

    public static AppClient getAppClient() {
        if (instance == null) {
            synchronized (AppClient.class) {
                if (instance == null) {
                    instance = new AppClient();
                }
            }
        }
        return instance;
    }

    public static void init(Api.ConfigParam configParam) {
        if(configParam != null) {
            Api.init(configParam);
            getAppClient();
        }
    }

    public static <T> T create(Class<T> cls) {
        return getProxy(0).create(cls);
    }

    private static ApiProxy getProxy(int type) {
        if (type == 0) {
            return Api.create(DefaultConfig.class);
        }else{
            return Api.create(DefaultConfig.class);
        }
    }

}
